package org.lyg.domain;

import org.lyg.validation.First;
import org.lyg.validation.Second;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;


public class User implements Serializable {
    private int id;
    @NotNull(message = "请填写账号",groups = Second.class)
    @Pattern(regexp = "([a-z]|[A-Z]|[0-9]|_|-|\\+|\\*|/){1,16}", message = "请输入1-16位大小写字母、符号（_-+*/）和数字", groups = Second.class)
    @NotEmpty(message = "请输入账号", groups = First.class)
    private String name;
    @NotNull(message = "请填写密码",groups = Second.class)
    @Pattern(regexp = "([a-z]|[A-Z]|[0-9]){8,16}", message = "请输入8-16位字母或数字", groups = Second.class)
    @NotEmpty(message = "请输入8-16位密码", groups = First.class)
    private String pwd;
    private String email;
    private Date createTime;
    private List<String> permissionList;
    private Boolean isLocked;
    private Boolean isDisable;
    private Integer pwdErrorCount;
    private Integer version;

    public User(int userId) {
        this.id=userId;
    }

    public User() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public List<String> getPermissionList() {
        return permissionList;
    }

    public void setPermissionList(List<String> permissionList) {
        this.permissionList = permissionList;
    }

    public Boolean isLocked() {
        return isLocked==null?false:isLocked;
    }

    public void setLocked(Boolean locked) {
        isLocked = locked;
    }

    public Boolean isDisable() {
        return isDisable==null?false:isDisable;
    }

    public void setDisable(Boolean disable) {
        isDisable = disable;
    }

    public Integer getPwdErrorCount() {
        return pwdErrorCount;
    }

    public void setPwdErrorCount(Integer pwdErrorCount) {
        this.pwdErrorCount = pwdErrorCount;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", pwd='" + pwd + '\'' +
                ", email='" + email + '\'' +
                ", createTime=" + createTime +
                ", permissionList=" + permissionList +
                ", isLocked=" + isLocked +
                ", isDisable=" + isDisable +
                ", pwdErrorCount=" + pwdErrorCount +
                ", version=" + version +
                '}';
    }
}
